var mongoose = require('mongoose')
mongoose.Promise = Promise;

var db = mongoose.createConnection('localhost', 'example1_test8')

db.once('open', function () {
    var ChildSchema = new mongoose.Schema({
        name: String
    })
    var ParentSchema = new mongoose.Schema({
        children1: [ChildSchema]
    },{strict: 'throw'})

    var ParentModel = db.model('Parent', ParentSchema)
    var parentEntity = new ParentModel({
        children1: [
            {
                name: 'aaaa'
            },
            {
                name: 'bbbb'
            }
        ]
    })
    ParentModel.find(function (err, parents) {
        console.log(parents[2].children1)
    })

    // parentEntity.save()
    //     .then(function () {
    //
    //     })
})